# 将输出数据写入到文件中

# 打开文件(路径 + 文件名)
# r""原生字符串
fstream1 = open(r"C:\Users\Zxm15\Desktop\text1.txt", mode="wt", encoding="utf-8")
print("testing for output", file=fstream1)
# 关闭文件
fstream1.close()

# 在文件中拼接新的数据,不会造成原有数据覆盖
fstream2 = open(r"C:\Users\Zxm15\Desktop\text2.txt", mode="a", encoding="utf-8")
print("testing for output", file=fstream2)
fstream2.close()